package com.zq.user;

import cn.dev33.satoken.secure.SaSecureUtil;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.zq.common.util.JwtUtil;
import com.zq.user.dao.entity.Users;
import com.zq.user.saconfig.UserStpUtil;
import com.zq.user.service.IUsersService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * @Author 张乔
 * @Date 2025/2/27 18:41
 */
@SpringBootTest
public class test {


    @Autowired
    private IUsersService userService;
    @Test
    void add(){
        Users user = new Users();
        user.setUsername("张乔");
        user.setPassword(SaSecureUtil.md5("111111"));
user.setEmail("2996809820@qq.com");
user.setPhone("13802965478");

        userService.save(user);
    }
@Test
    void mm(){
    UserStpUtil.login(1);
    SaTokenInfo tokenInfo = UserStpUtil.getTokenInfo();
    System.out.println(tokenInfo);

}

@Autowired
    private JwtUtil jwtUtil;


    @Test
    void jj(){
//        即使使用相同的id，只要登录的type（类型）不同，token值也是不同的
        StpUtil.login(1);
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        System.out.println("StpUtil的token值===========>"+tokenInfo);
        Integer stpId= jwtUtil.getUsernameFromToken(tokenInfo.getTokenValue());
        System.out.println("stpId的值====================>"+stpId);
        UserStpUtil.login(1);
        SaTokenInfo tokenInfo1 = UserStpUtil.getTokenInfo();
        System.out.println("UserStpUtil的token值===========>"+tokenInfo1);
        Integer stpId1= jwtUtil.getUsernameFromToken(tokenInfo1.getTokenValue());
        System.out.println("stpUser的值==================>"+stpId1);
    }

@Test
    void testEx(){
    boolean equals = "".equals("123");
    System.out.println(equals);

}




}
